package com.atguigu.daijia.driver.service.impl;

import com.atguigu.daijia.driver.service.FileService;
import com.atguigu.daijia.driver.service.MonitorService;
import com.atguigu.daijia.model.entity.order.OrderMonitorRecord;
import com.atguigu.daijia.model.form.order.OrderMonitorForm;
import com.atguigu.daijia.order.client.OrderMonitorFeignClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Service
@SuppressWarnings({"unchecked", "rawtypes"})
public class MonitorServiceImpl implements MonitorService {



    @Resource
    OrderMonitorFeignClient orderMonitorFeignClient;

    @Resource
    FileService fileService;
    @Override
    public Boolean upload(MultipartFile file, OrderMonitorForm orderMonitorForm) {
        String url = fileService.upload(file);

        OrderMonitorRecord monitorRecord = new OrderMonitorRecord();
        monitorRecord.setOrderId(orderMonitorForm.getOrderId());
        monitorRecord.setFileUrl(url);
        monitorRecord.setContent(orderMonitorForm.getContent());
        orderMonitorFeignClient.saveOrderMonitorRecord(monitorRecord);
        return true;
    }
}
